package com.atguigu.common.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author: 叶子
 * @date: 2022/02/25 15:26
 **/
public class RegexValidateUtils {
    static boolean flag = false;
    static String regex = "";

    public static boolean checkCellphone(String mobile) {
        String regex = "^((13[0-9])|(15([0-3]|[5-9]))|(18[0-9]))\\d{8}$";
        return check(mobile, regex);
    }

    private static boolean check(String str, String regex) {
        try {
            Pattern pattern = Pattern.compile(regex);
            Matcher matcher = pattern.matcher(str);
            flag = matcher.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }
}